AI Verified

Name

Create Admin User via FTP

About

This function creates a new administrator user account in WordPress.

Language

PHP

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

When you are locked out of your WordPress site and have no access to PHPMyAdmin, add this to your functions.php file to create a new admin user account. Remove it from the functions file after you’re successfully logged in. (The user will remain.)

Link for further information:

The author has provided the following URL that may be helpful to setting up or using this snippet:

https://wpwhatnot.com/create-admin-user-via-ftp/

Codevault

justin's vault

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.1

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

Snippet Source:

https://wpwhatnot.com/create-admin-user-via-ftp/

History

Last modified:

30/06/2023

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Potential vulnerability found : Hardcoded Credential
Found on line : 4
Code : ($pass='Password')
Vulnerable line : 4
Code : $pass='Password'

Found 1 vulnerabilities

Create Admin User via FTP

 
                    
1function wpb_admin_account(){
2 $user = 'Username';
3 $pass = 'Password';
4 $email = '[email protected]';
5 if ( !username_exists( $user ) && !email_exists( $email ) ) {
6 $user_id = wp_create_user( $user, $pass, $email );
7 $user = new WP_User( $user_id );
8 $user->set_role( 'administrator' );
9} }
10add_action('init','wpb_admin_account');

0

Related Snippets

Please see some snippets below related to this snippet..

WordPress Admin

AI Verified

1

Disable automatic scroll-to-notices when adding snippets

Added: 10 months ago

Last Updated: 10 months ago

By default, Code Snippets will scroll the page up so that new notices are visible when editing or adding snippets. This snippet disables that functionality for those who prefer a more consistent editi...

WordPress Admin

AI Verified

0

Remove admin bar for non-admin users

Added: 2 years ago

Last Updated: 1 year ago

This snippet will remove the black admin bar from the top of the window if the user is not an Administrator.

WordPress Admin

AI Verified

2

Disable admin notices by text string

Added: 2 years ago

Last Updated: 1 year ago

In $forbidden_message_strings array, provide a list of keywords or phrases that you want to disable. Provide a longer phrase to increase specificity

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

General

AI Verified

3

Default featured image

Added: 2 years ago

Last Updated: 2 months ago

This code defines a function named default_post_metadata__thumbnail_id that modifies the value of the _thumbnail_id metadata field for a post. The function takes five arguments: $value: The current...

WordPress Admin

AI Verified

2

Completely Disable Comments

Added: 1 year ago

Last Updated: 6 months ago

This will disable comments on the entire site

WordPress Admin

AI Verified

1

Disable Automatic Updates

Added: 1 year ago

Last Updated: 11 months ago

This will disable automatic updates